<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/3/29 0029
 * Time: 16:03
 */

namespace app\home\controller;
use think\Db;

class Yshome extends Base
{
        public function index(){
            //轮播图
            $data_banner = Db::name('banner')->where('is_del=0 and is_show=1 and sign="pc" and class_id=41')->order('sort desc,id desc')->field('banner_img,out_link')->select();
            $this->assign('data_banner',$data_banner);
            //客片底部广告
            $data_bannerfont = Db::name('banner')->where('is_del=0 and is_show=1 and sign="pc" and class_id=42')->order('sort desc,id desc')->field('banner_img,out_link')->limit(1)->find();
            $this->assign('data_bannerfont',$data_bannerfont);
            //内容
            $where=[
                'sign'=>"pc",
                'is_del'=>0,
                'is_show'=>1,
                'is_recom'=>1
            ];
            $data_jd = Db::name('psjd')->alias('w')->join('psjdclass c','w.class_id=c.class_id')->where($where)->order('w.sort desc,w.id desc')
                ->field('w.id,w.main_img,w.intro,w.create_time,w.title,c.name')
                ->select();
//                ->paginate(,false,['query' => request()->param()]);
//            $page = $data_jd->render();
//            $this->assign('page', $page);
            $this->assign('data_jd',$data_jd);
            return $this->fetch();
        }
        public function details($id=0,$nid=0,$pid=0){

        if(!empty($id)){
            $where['id']=$id;
            $where = [
                'a.sign'=>"pc",
                'a.is_del'=>0,
                'a.is_show'=>1,
                'a.id'=>$id
            ];
            $data_kp = Db::name('psjd')->alias('a')
                ->where($where)
                ->order('a.sort desc,a.id desc')
                ->find();
            $this->assign('data_kp',$data_kp);
        }else{
            return json(['code'=>0,'msg'=>'非法请求']);
        }
        //底部详情也广告
        $data_bannerfont = Db::name('banner')->where('is_del=0 and is_show=1 and sign="pc" and class_id=41')
            ->order('sort desc,id desc')->field('banner_img,out_link')->find();
        $this->assign('data_bannerfont',$data_bannerfont);
        //推荐客片
        $where = [
            'a.sign'=>"pc",
            'a.is_show'=>1,
            'a.is_del'=>0
        ];
        $data_kplist = Db::name('psjd')->alias('a')
            ->where($where)
            ->order('a.sort asc')
            ->paginate(12);
        $this->assign('data_kplist',$data_kplist);
        return $this->fetch();
    }



}